package main

import (
	"fmt"
	"time"
)

func testCloseChan()  {

	channel := make(chan struct{})
	go func() {
		// ... do something
		for i:=0;i<20;i++ {
			fmt.Println("product")
			channel <- struct{}{}
			time.Sleep(1*time.Second)
		}
	}()

	//
	go func() {
		for {
			select {
			case <-channel:
				fmt.Println("consumer 1")
			default:
				// .. do something
			}
		}
		fmt.Println("consumer 1 exit")
	}()


	//
	go func() {
		for {
			select {
			case <-channel:
				fmt.Println("consumer 2")
			default:
				// .. do something
			}
		}
		fmt.Println("consumer 2 exit")
	}()


	time.Sleep(time.Second*60)

	close(channel)
}